﻿using OP20.Models;

namespace OP20.ViewModels
{
    public class ST03CyManagerViewModel : BindableBase
    {
        private readonly IRegionManager _regionManager;

        public ST03CyManagerViewModel(IRegionManager regionManager)
        {
            _regionManager = regionManager;

            IsCheck01 = InductorParam_Global.aByPass[6];
            CylinderDelay.DelayTime01 = InductorParam_Global.aDelay[6];
        }
        #region 事件


        private DelegateCommand _GoBackCommand;

        public DelegateCommand GoBackCommand =>
            _GoBackCommand ?? (_GoBackCommand = new DelegateCommand(ExecuteGoBackCommand));

        void ExecuteGoBackCommand()
        {
            NavigationParameters param = new NavigationParameters();
            param.Add("StationName", "ST03");
            _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST03View, param);
        }

        /// <summary>
        /// 气缸感应器屏蔽
        /// </summary>
        private DelegateCommand<string> _CylinderPinBiCommand;
        public DelegateCommand<string> CylinderPinBiCommand =>
            _CylinderPinBiCommand ?? (_CylinderPinBiCommand = new DelegateCommand<string>(ExecuteCylinderPinBiCommand));

        void ExecuteCylinderPinBiCommand(string p)
        {
            switch (p)
            {
                case "ST3载具校验感应器":
                    InductorParam_Global.aByPass[6] = true;
                    break;

                default:
                    break;
            }
        }

        /// <summary>
        /// 气缸感应器解除屏蔽
        /// </summary>
        private DelegateCommand<string> _CylinderUnPinBiCommand;
        public DelegateCommand<string> CylinderUnPinBiCommand =>
            _CylinderUnPinBiCommand ?? (_CylinderUnPinBiCommand = new DelegateCommand<string>(ExecuteCylinderUnPinBiCommand));

        void ExecuteCylinderUnPinBiCommand(string p)
        {
            switch (p)
            {
                case "ST3载具校验感应器":
                    InductorParam_Global.aByPass[6] = false;
                    break;
                default:
                    break;
            }
        }
        private DelegateCommand<string> _TextChangeCommand;
        public DelegateCommand<string> TextChangeCommand =>
            _TextChangeCommand ?? (_TextChangeCommand = new DelegateCommand<string>(ExecuteTextChangeCommand));

        void ExecuteTextChangeCommand(string p)
        {
            switch (p)
            {
                case "DelayTime01":
                    InductorParam_Global.aDelay[6] = CylinderDelay.DelayTime01;
                    break;
                default:
                    break;
            }
        }

        #endregion


        #region 属性  

        private CylinderDelayModel _cylinderDelay;
        public CylinderDelayModel CylinderDelay
        {
            get { return _cylinderDelay ?? (_cylinderDelay = new CylinderDelayModel()); }
            set { SetProperty(ref _cylinderDelay, value); }
        }


        private bool _IsCheck01;
        public bool IsCheck01
        {
            get { return _IsCheck01; }
            set { SetProperty(ref _IsCheck01, value); }
        }


        private bool _IsCheck02;
        public bool IsCheck02
        {
            get { return _IsCheck02; }
            set { SetProperty(ref _IsCheck02, value); }
        }

        private bool _IsCheck03;
        public bool IsCheck03
        {
            get { return _IsCheck03; }
            set { SetProperty(ref _IsCheck03, value); }
        }

        private bool _IsCheck04;
        public bool IsCheck04
        {
            get { return _IsCheck04; }
            set { SetProperty(ref _IsCheck04, value); }
        }

        private bool _IsCheck05;
        public bool IsCheck05
        {
            get { return _IsCheck05; }
            set { SetProperty(ref _IsCheck05, value); }
        }


        private bool _IsCheck06;
        public bool IsCheck06
        {
            get { return _IsCheck06; }
            set { SetProperty(ref _IsCheck06, value); }
        }

        private bool _IsCheck07;
        public bool IsCheck07
        {
            get { return _IsCheck07; }
            set { SetProperty(ref _IsCheck07, value); }
        }
        #endregion
    }
}
